<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class BbsAnswerComment extends Model
{
    use SoftDeletes;
    
    protected $table="bbs_answer_comment";
    
    protected $primaryKey = 'id';
    
    protected $fillable = ['id','answer_id','message','user_id'];
    
    protected $dates = ['deleted_at'];

    /**
     * 根据评论获取回答模型
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function getAnswerByComment()
    {
        return $this->belongsTo('App\Models\BbsAnswerComment', 'answer_id');
    }

    /**
     * 获取用户名
     */
    public function getName()
    {
        return $this->hasOne('App\User','id','user_id');
    }
}
